-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schedule option #573
Schedule option #573
Conversation
start time. Signed-off-by: Otto van der Schaaf <[email protected]>
Signed-off-by: Otto van der Schaaf <[email protected]>
Signed-off-by: Otto van der Schaaf <[email protected]>
Signed-off-by: Otto van der Schaaf <[email protected]>
@qqustc Please review and assign back to me once ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Otto!
@@ -26,7 +29,8 @@ class OutputCollector { | |||
*/ | |||
virtual void addResult(absl::string_view name, const std::vector<StatisticPtr>& statistics, | |||
const std::map<std::string, uint64_t>& counters, | |||
const std::chrono::nanoseconds execution_duration) PURE; | |||
const std::chrono::nanoseconds execution_duration, | |||
const absl::optional<Envoy::SystemTime>& first_acquisition_time) PURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment for first_acquisition_time?
LGTM, assigned back to @dubious90 for review. |
@@ -24,7 +24,7 @@ class SequencerFactory { | |||
const SequencerTarget& sequencer_target, | |||
TerminationPredicatePtr&& termination_predicate, | |||
Envoy::Stats::Scope& scope, | |||
const Envoy::SystemTime scheduled_starting_time) const PURE; | |||
const Envoy::MonotonicTime scheduled_starting_time) const PURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not actionable, just making sure I'm understanding - this is where we're moving back to MonotonicTime to prevent #569 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is right.
@@ -26,7 +29,8 @@ class OutputCollector { | |||
*/ | |||
virtual void addResult(absl::string_view name, const std::vector<StatisticPtr>& statistics, | |||
const std::map<std::string, uint64_t>& counters, | |||
const std::chrono::nanoseconds execution_duration) PURE; | |||
const std::chrono::nanoseconds execution_duration, | |||
const absl::optional<Envoy::SystemTime>& first_acquisition_time) PURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will likely be addressed when the comment is added, but I'm not sure i understand what acquisition means in this context.
source/client/process_impl.cc
Outdated
@@ -179,7 +181,10 @@ void ProcessImpl::createWorkers(const uint32_t concurrency) { | |||
// TODO(oschaaf): Arguably, this ought to be the job of a rate limiter with awareness of the | |||
// global status quo, which we do not have right now. This has been noted in the | |||
// track-for-future issue. | |||
const auto first_worker_start = time_system_.systemTime() + kMinimalWorkerDelay; | |||
const Envoy::MonotonicTime monotonic_now = time_system_.monotonicTime(); | |||
const std::chrono::nanoseconds offset = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I might be misunderstanding but this ternary seems off to me. kMinimalWorkerDelay has the worker offsets baked into it, correct? So, if we are using a scheduled start time, and we aren't using minimal worker delay at all, then we aren't including any worker offsets from each other.
So now, batching behavior of nighthawk acts differently depending on whether or not we are using a schedule which doesn't seem right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This computes the start of the first worker, we will still be injecting an offset between each worker below. I refactored this for clarity, hopefully it's easier to read now.
source/client/process_impl.cc
Outdated
@@ -179,7 +181,10 @@ void ProcessImpl::createWorkers(const uint32_t concurrency) { | |||
// TODO(oschaaf): Arguably, this ought to be the job of a rate limiter with awareness of the | |||
// global status quo, which we do not have right now. This has been noted in the | |||
// track-for-future issue. | |||
const auto first_worker_start = time_system_.systemTime() + kMinimalWorkerDelay; | |||
const Envoy::MonotonicTime monotonic_now = time_system_.monotonicTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three comments here:
- This has gotten complex enough (especially with the long comments above to explain what's going on), that I think it might warrant its own privately scoped function. CalculateWorkerStartTime_ or something?
source/client/process_impl.cc
Outdated
const auto first_worker_start = time_system_.systemTime() + kMinimalWorkerDelay; | ||
const Envoy::MonotonicTime monotonic_now = time_system_.monotonicTime(); | ||
const std::chrono::nanoseconds offset = | ||
schedule.has_value() ? schedule.value() - time_system_.systemTime() : kMinimalWorkerDelay; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We are heavily explaining the workerdelay behavior here in the comment above. Can we add a one-line comment for how the schedule behavior fits in? For instance, if I am wrong about point 2 above, we should say why the scheduled workers don't need an offset delay.
/** | ||
* @return absl::optional<Envoy::SystemTime> Time of the first acquisition, if any. | ||
*/ | ||
virtual absl::optional<Envoy::SystemTime> firstAcquisitionTime() const PURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might have just missed it in this pull request (if so, please point me to the right file), but while I'm seeing code that writes this field or passes it around, I'm not finding where it's actually used functionally. What is its intended purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets consumed over at https://github.com/envoyproxy/nighthawk/pull/573/files#diff-e528c3973715873e2ec7fcac6a842e5d9a59d6523a77bf1219d295dd4c7285cdR539 and ends up in the output as execution_start
.
Signed-off-by: Otto van der Schaaf <[email protected]>
Signed-off-by: Otto van der Schaaf <[email protected]>
Signed-off-by: Otto van der Schaaf <[email protected]>
for clarity. Signed-off-by: Otto van der Schaaf <[email protected]>
@dubious90 Thanks for the feedback, I think I addressed it. Extracted the worker start time & offset calculations into their own methods for clarity. Ready for another round! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for the readability changes! It's really easy to follow what's happening now.
Adds a new schedule option to the proto api., which allows specifying a date/time
at which execution should start.
Should also fix #569 by reducing reliance on
Envoy::SystemTime
to a minimum:Based on the value schedule option, a monotonic time will be computed
and propagated. This makes us use
Envoy::MonotonicTime
again in placeswhere sub ms resolution is a must have. (The fix will need confirmation, as I
couldn't get
--config=libc++
to work for other reasons.)